package com.example.geometryshader;

import android.opengl.GLES30;
import android.opengl.GLES32;

public class GLUniformManager {
    private GLUniformManager() {}

    /**
     * @brief 设置mat4 float元素类型的uniform
     * @param shaderID 着色器ID
     * @param uniformName 统一变量的名称
     * @param matrix 矩阵（必须是列主序）
     */
    public static void setUniformMatrix4fv(int shaderID, String uniformName, float[] matrix){
        int mvpMatrixLocation = GLES30.glGetUniformLocation(shaderID, uniformName);
        GLES32.glUniformMatrix4fv(mvpMatrixLocation, 1, false, matrix, 0);
    }

    public static void setUniform1fv(int shaderID, String uniformName, float value){
        int valueLocation = GLES30.glGetUniformLocation(shaderID, uniformName);
        GLES32.glUniform1f(valueLocation, value);
    }
}
